#encoding:utf-8
# 配置参数
class TrainingConfig(object):
    epoches = 100
    evaluateEvery = 100
    checkpointEvery = 100
    learningRate = 1e-3
    lrDecay= 0.5          #learning rate decay
    clip= 5.0              #gradient clipping threshold
    l2RegLambda=0.05     #l2 regularization lambda
    
class Config(object):
    def __init__(self):
        self.layerType = "textCNN"
        '''
            linux：服务器 
            local：本地 batch
            single: 本地句子预测
        '''
        self.status = "local"  

        self.sequenceLength = 2000  # 取了所有序列长度的均值
        self.batchSize = 128
        # self.dataSource = "../../data/train_set_demo.csv"
        self.textName = "text"
        self.labelName = "label"
        self.isCleanStopWord = False
        self.numClasses = 14  # 二分类设置为1，多分类设置为类别的数目
        self.rate = 0.9  # 训练集的比例
        self.dropoutKeepProb = 0.5 
        self.embeddingSize = 100
        self.wordvecType=""
        self.training = TrainingConfig()
        self.wordFred = 1
        self.textStatus =  '_re'
        self.iter = 50
        self.training.evaluateEvery =100
        self.training.checkpointEvery =100
        commonPath = "../data/"
        vecPath ="../vec/"
        if self.status=="linux":
            self.dataSource = commonPath+"train_set"+self.textStatus+".csv"
            self.testFileSource = commonPath+"test_a"+self.textStatus+".csv"
            self.training.epoches =100
        else:
            self.dataSource = commonPath+"train_set_demo"+self.textStatus+".csv"
            self.testFileSource = commonPath+"test_demo"+self.textStatus+".csv"
            self.training.epoches =10
            
        self.wordvecType="fasttext" 
        self.fasttextModel = 'skipgram'
        if self.wordvecType=="fasttext":
            self.embedingSource = vecPath+self.fasttextModel+self.textStatus+".vector"
        else:
            self.embedingSource = vecPath+"corpus_"+str(self.embeddingSize)+"d_iter"+str(self.iter)+self.textStatus+".vector"
        self._fasttextEmbedingSource = vecPath+self.fasttextModel+""+self.textStatus+".bin"
        self.testFileSourceOutput = commonPath+self.layerType+"_pred_score"+self.textStatus+".csv"
    
        self.stopWordSource = commonPath+"stopword.txt"
        self.word2idxSource = commonPath+"word2idx"+self.textStatus+".json"
        self.label2idxSource = commonPath+"label2idx"+self.textStatus+".json"

        if self.layerType == "textCNN":
            from layers.textcnn import ModelConfig
        elif self.layerType=="textRNN":
            from layers.textrnn import ModelConfig
        elif self.layerType=="BiLSTMAttention":
            from layers.BiLSTMAttention import ModelConfig
        elif self.layerType=="textrcnn":
            from layers.textrcnn import ModelConfig
        elif self.layerType=="AdversarialLSTM":
            from layers.AdversarialLSTM import ModelConfig
        elif self.layerType=="Transformer":
            from layers.Transformer import ModelConfig
        self.model = ModelConfig()
